package com.example.app.service;

import com.example.app.entity.Conversation;
import com.example.app.mapper.ConversationMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ConversationService {
    @Resource
    private ConversationMapper conversationMapper;

    public List<Conversation> getRecentConversations(Long userId) {
        List<Conversation> conversations = conversationMapper.getConversationsByUserId(userId);
        return conversations;
    }

    public Long getConversationId(Long fromUserId, Long toUserId) {
        Conversation conversation = conversationMapper.getConversationBetween(fromUserId, toUserId);
        return conversation.getId();
    }
}
